BX.namespace("BX.UI");if(typeof BX.UI.EntityModel==="undefined"){BX.UI.EntityModel=function(){this._id="";this._settings={};this._isIdentifiable=true;this._data=null;this._initData=null;this._lockedFields=null;this._changeNotifier=null;this._lockNotifier=null;this.eventsNamespace="UI.EntityModel"};BX.UI.EntityModel.prototype={initialize:function(t,i){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=i?i:{};this._isIdentifiable=BX.prop.getBoolean(this._settings,"isIdentifiable",true);this._data=BX.prop.getObject(this._settings,"data",{});this._initData=BX.clone(this._data);this._lockedFields={};this.doInitialize()},doInitialize:function(){},getEventArguments:function(){return{entityTypeName:this.getEntityTypeName(),entityId:this.getEntityId()}},getEntityTypeName:function(){return""},isIdentifiable:function(){return this._isIdentifiable},getEntityId:function(){return BX.prop.getInteger(this._data,"ID",0)},hasField:function(t){return this._data.hasOwnProperty(t)},getField:function(t,i){if(i===undefined){i=null}return BX.prop.get(this._data,t,i)},getStringField:function(t,i){if(i===undefined){i=null}return BX.prop.getString(this._data,t,i)},getIntegerField:function(t,i){if(i===undefined){i=null}return BX.prop.getInteger(this._data,t,i)},getNumberField:function(t,i){if(i===undefined){i=null}return BX.prop.getNumber(this._data,t,i)},getArrayField:function(t,i){if(i===undefined){i=null}return BX.prop.getArray(this._data,t,i)},registerNewField:function(t,i){this._data[t]=i;this._initData[t]=i},setField:function(t,i,e){if(this._data.hasOwnProperty(t)&&this._data[t]===i){return}this._data[t]=i;if(!BX.type.isPlainObject(e)){e={}}if(BX.prop.getBoolean(e,"enableNotification",true)){var n=this.getEventArguments();n.fieldName=t;BX.onCustomEvent(window,this.eventsNamespace+".Change",[this,n]);if(this._changeNotifier&&BX.type.isFunction(this._changeNotifier.notify)){this._changeNotifier.notify([{name:t,originator:BX.prop.get(e,"originator",null)}])}}},getData:function(){return this._data},setData:function(t,i){this._data=BX.type.isPlainObject(t)?t:{};this._initData=BX.clone(this._data);if(BX.prop.getBoolean(i,"enableNotification",true)){var e=this.getEventArguments();e.forAll=true;BX.onCustomEvent(window,this.eventsNamespace+".Change",[this,e]);if(this._changeNotifier&&BX.type.isFunction(this._changeNotifier.notify)){this._changeNotifier.notify([{forAll:true,originator:BX.prop.get(i,"originator",null)}])}}},updateData:function(t,i){if(!BX.type.isPlainObject(t)){return}this._data=BX.mergeEx(this._data,t);if(BX.prop.getBoolean(i,"enableNotification",true)){var e=this.getEventArguments();e.forAll=true;BX.onCustomEvent(window,this.eventsNamespace+".Change",[this,e]);if(this._changeNotifier&&BX.type.isFunction(this._changeNotifier.notify)){this._changeNotifier.notify([{forAll:true,originator:BX.prop.get(i,"originator",null)}])}}},updateDataObject:function(t,i,e){if(!this._data.hasOwnProperty(t)){this._data[t]=i}else{this._data[t]=BX.mergeEx(this._data[t],i)}if(BX.prop.getBoolean(e,"enableNotification",true)){var n=this.getEventArguments();n.forAll=true;BX.onCustomEvent(window,this.eventsNamespace+".Change",[this,n]);if(this._changeNotifier&&BX.type.isFunction(this._changeNotifier.notify)){this._changeNotifier.notify([{forAll:true,originator:BX.prop.get(e,"originator",null)}])}}},getInitFieldValue:function(t,i){if(i===undefined){i=null}return BX.prop.get(this._initData,t,i)},setInitFieldValue:function(t,i){if(this._initData.hasOwnProperty(t)&&this._initData[t]===i){return}this._initData[t]=i},getSchemeField:function(t,i,e){return this.getField(t.getDataStringParam(i,""),e)},setSchemeField:function(t,i,e){var n=t.getDataStringParam(i,"");if(n!==""){this.setField(n,e)}},getMappedField:function(t,i,e){var n=BX.prop.getString(t,i,"");return n!==""?this.getField(n,e):e},setMappedField:function(t,i,e){var n=BX.prop.getString(t,i,"");if(n!==""){this.setField(n,e)}},save:function(){},rollback:function(){this._data=BX.clone(this._initData)},lockField:function(t){if(this._lockedFields.hasOwnProperty(t)){return}this._lockedFields[t]=true;if(this._lockNotifier&&BX.type.isFunction(this._lockNotifier.notify)){this._lockNotifier.notify([{name:t,isLocked:true}])}},unlockField:function(t){if(!this._lockedFields.hasOwnProperty(t)){return}delete this._lockedFields[t];if(this._lockNotifier&&BX.type.isFunction(this._lockNotifier.notify)){this._lockNotifier.notify([{name:t,isLocked:false}])}},isFieldLocked:function(t){return this._lockedFields.hasOwnProperty(t)},isCaptionEditable:function(){return false},getCaption:function(){return""},setCaption:function(t){},prepareCaptionData:function(t){},addChangeListener:function(t){if(this._changeNotifier&&BX.type.isFunction(this._changeNotifier.addListener)){this._changeNotifier.addListener(t)}},removeChangeListener:function(t){if(this._changeNotifier&&BX.type.isFunction(this._changeNotifier.removeListener)){this._changeNotifier.removeListener(t)}},addLockListener:function(t){if(this._lockNotifier&&BX.type.isFunction(this._lockNotifier.addListener)){this._lockNotifier.addListener(t)}},removeLockListener:function(t){if(this._lockNotifier&&BX.type.isFunction(this._lockNotifier.removeListener)){this._lockNotifier.removeListener(t)}}};BX.UI.EntityModel.create=function(t,i){var e=new BX.UI.EntityModel;e.initialize(t,i);return e}}
//# sourceMappingURL=model.map.js